package org.dromara.common.core.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

/**
 * 运行环境工具类
 *
 * @author zlj
 * @since 2023/4/23
 */
@Configuration
public class ProfilesUtils {

    /**
     * 环境后门放行
     *
     * @return 判断 true: 生产环境   false: 开发环境
     */
    public static boolean check() {
        try {
            SpringUtils.getBean("profilesBackdoor");
            return false;
        } catch (BeansException e) {
            //无bean
        }
        return true;
    }

    /**
     * 验证码后门 生产环境自动禁用
     */
    @Profile(value = {"dev", "local", "test"})
    @Bean
    public void profilesBackdoor() {
    }

}
